D▌SK B▌LG▌LER▌N▌ ╓╨RENMEKOkurlar²m²zdan s²k s²k programlar²n² kopyalanmaya kar■² nas²l koruyacaklar², disk bilgilerini nas²l alacaklar² yoluna sorular al²yoruz. Bundan uzun sⁿre ÷nce bu k÷■ede verdi≡imiz API'ler ile disk ⁿzerinde ne kadar yer kald²≡²n², sistem kaynaklar²n²n nas²l bulunaca≡²n² anlatt²k. De≡inmedi≡imiz bir konu ise disk seri numaras²n²n ve etiketinin bulunmas²yd².A■a≡²daki programc²k diledi≡iniz sⁿrⁿcⁿnⁿn seri numaras²n² ve etiketini komut butonuna bas²ld²≡²nda size veriyor. PathName$ = "à sat²r²n² de≡i■tirerek istedi≡iniz sⁿrⁿcⁿyⁿ seτebilirsiniz... ' Formdan ayr² bir BAS modⁿlⁿne girecek: Option Explicit Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long 'A■a≡²daki kodlar²n hepsi formun General - Declarations b÷lⁿmⁿne girecek Private Sub cmdVolumeInfo_Click() Dim r As Long Dim PathName As String Dim DrvVolumeName As String Dim DrvSerialNo As String PathName$ = "c:\" rgbGetVolumeInformationRDI PathName$, DrvVolumeName$, DrvSerialNo$ 'Sonuτlar² G÷rⁿntⁿle Print: Print " Sⁿrⁿcⁿ ▌statistikleri ", ": "; UCase$(PathName$) Print: Print " Disk Etiketi ", ": "; DrvVolumeName$ Print " Seri Numaras²", ": "; DrvSerialNo$ End Sub Private Sub Form_Load() Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2 End Sub Function GetHiWord(dw As Long) As Integer If dw& And &H80000000 Then GetHiWord% = (dw& \ 65535) - 1 Else: GetHiWord% = dw& \ 65535 End If End Function Function GetLoWord(dw As Long) As Integer If dw& And &H8000& Then GetLoWord% = &H8000 Or (dw& And &H7FFF&) Else: GetLoWord% = dw& And &HFFFF& End If End Function Private Sub rgbGetVolumeInformationRDI(PathName$, DrvVolumeName$, DrvSerialNo$) Dim r As Long Dim pos As Integer Dim HiWord As Long Dim HiHexStr As String Dim LoWord As Long Dim LoHexStr As String Dim VolumeSN As Long Dim MaxFNLen As Long Dim UnusedStr As String Dim UnusedVal1 As Long Dim UnusedVal2 As Long DrvVolumeName$ = Space$(14) UnusedStr$ = Space$(32) r& = GetVolumeInformation(PathName$, _ DrvVolumeName$, Len(DrvVolumeName$), VolumeSN&, _ UnusedVal1&, UnusedVal2&, UnusedStr$, Len(UnusedStr$)) If r& = 0 Then Exit Sub pos% = InStr(DrvVolumeName$, Chr$(0)) If pos% Then DrvVolumeName$ = Left$(DrvVolumeName$, pos% - 1) If Len(Trim$(DrvVolumeName$)) = 0 Then DrvVolumeName$ = "(no label)" HiWord& = GetHiWord(VolumeSN&) And &HFFFF& LoWord& = GetLoWord(VolumeSN&) And &HFFFF& HiHexStr$ = Format$(Hex(HiWord&), "0000") LoHexStr$ = Format$(Hex(LoWord&), "0000") DrvSerialNo$ = HiHexStr$ & "-" & LoHexStr$ End Sub |